import requests


video_url = 'https://www.douyin.com/channel/300209'

response = requests.get(video_url)


response_body_length = int(response.headers.get("Content-Length"))
print(response_body_length)


# 获取响应内容存储到文件
with open("抖音.mp4", 'wb') as fd:
    write_length = 0
    for chunk in response.iter_content(chunk_size=100):
        write_length += fd.write(chunk)  # write的返回值为写入到文件内容的多少
        print("下载进度: %02.2f%%" % (100 * write_length / response_body_length))
